package zhtt.action05_interceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;

import java.io.IOException;

/**
 * Created by zhtt on 2017/4/18.
 */
public class Demo01Action extends ActionSupport{

    /**
     * 拦截此URL，
     * 如果拦截全部URL则设置：<interceptor-ref name="digitCertificateCheck"/>
     * @return
     */
    @Action(interceptorRefs={@InterceptorRef("digitCertificateCheck"),
            @InterceptorRef("digitCertificateCheck")})
    public String execute() {
        try {
            ServletActionContext.getResponse().getOutputStream().write("Hello".getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Action("url")
    public String doSomething() {
        return SUCCESS;
    }
}
